package gameserver;

/** Stop-watch class to time blocks of code. **/
public class EventTimer {
    private long startTime = 0;
    private long stopTime = 0;
    private boolean running = false;

    public void startTimer() {
        this.startTime = System.currentTimeMillis();
        this.running = true;
    }

    public void stopTimer() {
        this.stopTime = System.currentTimeMillis();
        this.running = false;
    }

    public long getElapsedTime() {
        if (running)
            return System.currentTimeMillis() - startTime;
        return stopTime - startTime;
    }

    public long getElapsedTimeSecs() {
        if (running)
            return (System.currentTimeMillis() - startTime) / 1000;
        return (stopTime - startTime) / 1000;
    }
}